﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using KC.Framework.Extension;
using KC.Enums;
using KC.DTO.Core;
using ProtoBuf;

namespace KC.DTO.Account
{
    [Serializable, DataContract(IsReference = true)]
    [ProtoContract]
    public class HomeContentDTO : EntityDTO
    {
        [DataMember]
        [ProtoMember(1)]
        public int Id { set; get; }
        [DisplayName("通知类型")]
        [Required]
        [DataMember]
        [ProtoMember(2)]
        public HomeContentType ContentType { set; get; }
        [DisplayName("详细内容")]
        [Required]
        [DataMember]
        [ProtoMember(3)]
        public string Content { set; get; }
        [DisplayName("发布时间")]
        [Required]
        [DataMember]
        [ProtoMember(4)]
        public DateTime ReleaseDate { set; get; }
        [DisplayName("发布时间（展示使用）")]
        [DataMember]
        public string ReleaseTime
        {
            get
            {
                return ReleaseDate.ToString("yyyy-MM-dd HH:mm:ss");
            }
        }
        [DisplayName("描述")]
        [Required]
        [DataMember]
        [ProtoMember(5)]
        public string Describe { set; get; }
        [DisplayName("发布人")]
        [Required]
        [DataMember]
        [ProtoMember(6)]
        public string Publisher { set; get; }
        [DisplayName("标题")]
        [Required]
        [DataMember]
        [ProtoMember(7)]
        public string Title { set; get; }

        private string _contentTypeStr;
        [DataMember]
        [ProtoMember(8)]
        public string ContentTypeStr
        {
            set { _contentTypeStr = value; }
            get{return ContentType.ToDescription();}
        }


        private bool _canEdit=false;
        /// <summary>
        /// 是否有权限编辑
        /// </summary>
        [DataMember]
        [ProtoMember(9)]
        public bool CanEdit {
            set
            {
                _canEdit = value;
            }
            get
            {
                return _canEdit;
            } 
        }
    }
}
